<template>
	<div class="new-modal">
		<div class="new-modal-title">
			{{title}}
			<i class="ion-close-round delete" @click="genderDelete()"></i>
		</div>
		<div class="new-modal-section">
			<span v-for="(item,index) of genderOptions" :class="{on:index==gender}" @click="genderChange(index)">
				<i class="ion-checkmark-circled"></i>
				{{item.shopName}}
			</span>
		</div>
	</div>
</template>

<script>
	import { bus } from 'bus.js'
	export default{
		data:function(){
			return {
				//shopId 当前状态
				gender:999,
				genderOptions:[],
				shopId:'',
				title:'车商列表'
			}
		},
		methods:{
			genderChange(e){
				this.gender = e		
				this.$emit('modalChange',this.genderOptions[this.gender].shopId)
//				console.log(this.shopId)
			},
			genderDelete(){
				if(this.userSession.shopId){					
					this.$emit('modalChange',this.genderOptions[this.gender].shopId)
				}else{
					this.gender = 999
					this.$emit('modalChange','')
				}
				
			},
			shopIdGet(){
				window.axios.get(baseUrl+'/controller/getShopList',{
					params:{
						marketId:this.userSession.marketId,
						shopId:this.userSession.shopId?this.userSession.shopId:'',
						shopState:1
					}
				}).then((res)=>{
					this.genderOptions=res.data.result
					for(var i = 0;i<this.genderOptions.length;i++){
						if(this.genderOptions[i].shopId == this.shopId)
							this.gender = i
					}
				})
			}
		},
		mounted:function(){
		},
		computed: {
			// 获取缓存数据
			userSession() {
				return sess.get('userSession')
			}
		},
		created: function(){
//			console.log(this.$store.state.shopId)
			this.shopId = this.$store.state.shopId
			this.shopIdGet()
		}
	}
</script>
